package com.flyoil.petromp.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyoil.petromp.R;

/**
 * Created by songzhiiyn on 2017/10/11.
 * 自定义搜索框提示view，只能设置点击事件和设置提示文本
 */

public class SearchDataHint extends LinearLayout {
    private TextView tv_message;
    private View view;

    public SearchDataHint(Context context) {
        super(context);
        initview(context);
    }

    public SearchDataHint(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initview(context);
    }

    public SearchDataHint(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initview(context);
    }

    private void initview(Context context) {
        view = LayoutInflater.from(context).inflate(R.layout.view_search_hint_layout, this);
        tv_message = view.findViewById(R.id.tv_search_data_message);
//        setViewOnclick();
    }




    /**
     * 设置提示文本
     */
    public void setSearchHint(String hint) {
        if (tv_message != null) {
            tv_message.setText(hint);
        }
    }

    private void setViewOnclick() {
//        img_delete.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                edt_message.setText("");
//            }
//        });
//        edt_message.setOnEditorActionListener(new TextView.OnEditorActionListener() {
//            @Override
//            public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
//                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
//                    // 当按了搜索之后关闭软键盘
//
//                    if (activity != null) {
//                        EditText_util.hideKeyboard(activity);
//                    }
//                    if (searchListener != null) {
//                        searchListener.OnSearchData(edt_message.getText().toString());
//                    }
//                    return true;
//                }
//                return false;
//            }
//        });
    }



}
